#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int f0=0,f1=1;
	while(f1<=n){
		int k=f0;
		f0=f1;
		f1=k+f0;
	}
	if(abs(n-f0)<=abs(n-f1)) cout<<f0;
	else cout<<f1;
	return 0;
}
